<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.qijia.travel.app.*"  %>
<%@ page import="com.qijia.travel.domain.*"  %>
<%@ page import="com.qijia.travel.common.*"  %>
<%
Guide guide = (Guide)session.getAttribute(Constants.USER_KEY);
if(guide.getGuideType()==null||guide.getGuideType()!=1)
out.println("<script>alert('你没有此权限，请联系管理员开通此权限!');window.close();window.parent.location.reload();</script>");

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

TreamManager treamManager = new TreamManager();
GuideManager guideManager = new GuideManager();

List<Tream> treams = treamManager.getTreamByExample();

String guideId = request.getParameter("guideId");
guide = new Guide();

try{
   int ID = Integer.parseInt(guideId);
   guide = guideManager.getGuideById(ID);
   if(guide==null){
      out.println("<script>alert('该导游不存在');</script>");
      response.sendRedirect("guideManage.jsp");
   }
}catch(NumberFormatException e){
   out.println("<script>alert('该导游不存在');</script>");
   response.sendRedirect("guideManage.jsp");
 }catch(AppErrorException ex){
   out.println("<script>alert('获取数据失败!');</script>");
   response.sendRedirect("guideManage.jsp");
}

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	margin:0;
	padding:10px 0;
	font-size:12px;
}
ul,li{
    list-style:none;
}
textarea{width:150px;font-size:12px;}
.ipt{width:150px;}
.ipt2{width:40px;}
.btn{border:#002d96 1px solid; padding:4px 4px 2px; font-size:12px; filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#FFFFFF, EndColorStr=#9DBCEA); cursor:hand; color:black;}
#wrapper{
	width:310px;
	height:160px;
	margin:0 auto;
	overflow:hidden;
}
#content{
    float:left;
	width:310px;
	height:auto;
	padding:10px 0;
}

-->
</style>
</head>

<body>
<div id="wrapper">
    <form method="post" action="">
    <div id="content">
	    <ul>
	        <li><span>导游姓名：</span><input id="title" type="text" readonly="readonly" value="<%=guide.getGuideName()%>"/><input id="guide" type="hidden" value="<%=guide.getGuideId()%>"/></li>
	        <li>&nbsp;&nbsp;&nbsp;&nbsp;</li>
	        <li><span>设置团队：</span><select id="tream" name="tream">
	                  <% for(Tream tream:treams){ %>
	                     <option value="<%=tream.getTreamId()%>" <% if(tream.getTreamName().equals(guide.getTreamName()))out.print("selected='selected'"); %>><%=tream.getTreamName()%></option>
	                  <% } %>
	            </select>
	        </li>
	        <li>&nbsp;&nbsp;&nbsp;&nbsp;</li>
			<li style="padding:0 0 0 100px;"><input onclick="saveGuideToTream()" name="" type="button" class="btn" value="确定" /></li>
		</ul>
	</div>
	</form>
</div>
<script src="<%=basePath%>dwr/interface/guideManager.js"></script>
<script src="<%=basePath%>dwr/engine.js"></script>
<script type="text/javascript">
  function saveGuideToTream(){
    var tream=document.getElementById("tream").value;
    guideManager.saveGuideToTream('<%=guide.getGuideId()%>',tream,function(data){
          alert("保存成功!");
          window.close();
          window.parent.location.reload();
    });
  }
</script>
</body>
</html>
